

<?php

if ($this->code == "0") {
    echo "<legend>";
    echo $this->msg;
    echo "</legend>";
} else
    
    echo $this->msg;

if ($this->code == "") {
    ?>

<legend>Follow Up Penarikan Saldo</legend>
    <div class="row clearfix">
        <div class="col-md-8 column">

        <form method="post" id="frm" name="frm">
                <br>
                <!-- fromAcc input-->
                <div class="form-group">
                    <label class="control-label">Dari Nomor Akun</label>
                    <input type="text" class="form-control" name="acc_num1" id="acc_num1" value="<?php echo $this->data['acc_num1']; ?>" readonly>
                    <input type="hidden" name="trans_hid" id="trans_hid" value="<?php echo $this->data['trans_header_id']; ?>">
                </div>


                <div>
                    <label class="control-label">Jumlah Penarikan</label>
                    <input type="text" class="form-control" name="amt_rp" id="amt_rp" value="<?php echo $this->data['amt_rp']; ?>" readonly>


                </div>
                
                <div>
                    <label class="control-label">Transfer ke Bank</label>
                    <input placeholder="Rekening Bank" class="form-control" type="text" name="bank_name" id="bank_name" value="<?php echo "[".$this->data['bank_account_no']."] ".$this->data['bank_name']." (".$this->data['member_name'].")"; ?>" readonly></input>
                    <input type="hidden" name="acc_num2" id="acc_num2" value="<?php echo $this->data['acc_num2']; ?>">
                    <input type="hidden" name="bank_name" id="bank_name" value="<?php echo $this->data['bank_name']; ?>">
                    <input type="hidden" name="member_name" id="member_name" value="<?php echo $this->data['member_name']; ?>">
                </div>


                <!-- submit btn-->
                <div class="form-group">
                    <label class="control-label"></label>
                    <div class="controls">
                        <button class="btn btn-default" type="button" id="btnAPPROVE" name="btnAPPROVE" onclick="btnClick('APPROVE')">
                            Approve</button>
                        <button class="btn btn-default" type="button" id="btnCANCEL" name="btnCANCEL" onclick="btnClick('CANCEL')">
                            Cancel</button>
                        
                        <input type="hidden" name="flag" id="flag" value="">
                        <div id="div_result"></div>
                        <p class="help-block"></p>
                    </div>
                </div>



            </form>

</div>
</div>

<script>

    $("#frm").submit(function(event) {

        /* Stop form from submitting normally */
        event.preventDefault();

        var flag = $('#flag').val();

        /* Clear result div*/
        $("#div_result").html('');
        $("#btn"+flag).html('Memproses...');
        $("#btn"+flag).attr('disabled','disabled');

        /* Get some values from elements on the page: */
        var values = $(this).serialize();

        var msg = [];

        /* Send the data using post and put the results in a div */

        $.ajax({
            url: "/approval/followupwithdraw/",
            type: "post",
            data: values,
            success: function(response, opts){

                //alert(response);


                var cekSess = response.toUpperCase().search("SESSION TIMEOUT");

                if (cekSess < 0){
                    var cekStatus = response.toUpperCase().search("ERROR");

                    if (cekStatus < 0){
                        $("#div_content").html(response);
                    }else{

                        var resp = response.replace('ERROR', '');

                        msg.push('<span>'+resp+'</span>');
                        $.messager.alert('Info', msg.join('<br/>'));

                        //$("#div_result").html(resp);
                        $("#btn"+flag).removeAttr('disabled');
                        $("#btn"+flag).html(flag);
                    }
                }else{
                    location.href='<?php echo $this->baseUrl() ?>/index/login/msg/Session Timeout silahkan login kembali !';
                }

            },
            error:function(response, opts){
                //alert("failure");
                //$("#div_result").html(response);
                msg.push('<span>'+response+'</span>');
                $.messager.alert('Info', msg.join('<br/>'));

                $("#btn"+flag).removeAttr('disabled');
            }
        });

    });

    
    function btnClick(flag){
        $('#flag').val(flag);

        if (confirm(flag+' Penarikan?')){
            $('#frm').submit();
        }
    }
    
   

</script>

<?php } ?>